package com.hospital.workstation.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.hospital.workstation.domain.PharmacyAssess;
import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hospital.common.annotation.RepeatSubmit;
import com.hospital.common.annotation.Log;
import com.hospital.common.core.controller.BaseController;
import com.hospital.common.core.domain.PageQuery;
import com.hospital.common.core.domain.R;
import com.hospital.common.core.validate.AddGroup;
import com.hospital.common.core.validate.EditGroup;
import com.hospital.common.core.validate.QueryGroup;
import com.hospital.common.enums.BusinessType;
import com.hospital.common.utils.poi.ExcelUtil;
import com.hospital.workstation.domain.vo.PharmacyAssessVo;
import com.hospital.workstation.domain.bo.PharmacyAssessBo;
import com.hospital.workstation.service.IPharmacyAssessService;
import com.hospital.common.core.page.TableDataInfo;

/**
 * 入院药学评估
 *
 * @author whb
 * @date 2023-02-10
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/workstation/pharmacyAssess")
public class PharmacyAssessController extends BaseController {

    private final IPharmacyAssessService iPharmacyAssessService;

    /**
     * 查询入院药学评估详细信息
     *
     * @param medicalRecodeNo 病历号
     * @return
     */
    @SaCheckPermission("workstation:pharmacyAssess:medicalRecodeNo")
    @GetMapping("/{medicalRecodeNo}")
    public R<PharmacyAssessVo> getInfoByMedicalRecodeNo(@PathVariable Integer medicalRecodeNo) {
        return R.ok(iPharmacyAssessService.queryByMedicalRecodeNo(medicalRecodeNo));
    }

    /**
     * 保存入院药学评估
     */
    @SaCheckPermission("workstation:pharmacyAssess:add")
    @Log(title = "入院药学评估", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody PharmacyAssessBo bo) {
        return iPharmacyAssessService.insertByBo(bo);
    }
}
